package com.twu.biblioteca;
import java.io.*;
import java.util.*;
public class Library extends Book
{
    ArrayList<Book> Bk = new ArrayList<Book>();
    Book b1,b2,b3,b4;
    ArrayList<Movie> Mv=new ArrayList<Movie>();
    Movie m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15;
    ArrayList<Member> Mem = new ArrayList<Member>();
    Member mr1,mr2,mr3,mr4;
    Library()
    {
        //To add books to the Library
        b1=new Book(1,"aa","bb","cc");
        b2=new Book(2,"A","B","C");
        b3=new Book(3,"A","B","C");
        b4=new Book(4,"A","B","C");
        Bk.add(b1);
        Bk.add(b2);
        Bk.add(b3);
        Bk.add(b4);

        //To add movies to the library
       m1=new Movie("xx",1992,"xxx","10");
       m2=new Movie("yy",1993,"xxx","10");
       m3=new Movie("aa",1994,"xxx","10");
       m4=new Movie("bb",1995,"xxx","10");
       m5=new Movie("cc",1996,"xxx","10");
       m6=new Movie("dd",1997,"xxx","10");
       m7=new Movie("ee",1998,"xxx","10");
       m8=new Movie("ff",1999,"xxx","10");
       m9=new Movie("xx",1992,"xxx","10");
       m10=new Movie("xx",1992,"xxx","10");
       m11=new Movie("xx",1992,"xxx","10");
       m12=new Movie("xx",1992,"xxx","10");
       m13=new Movie("xx",1992,"xxx","10");
       m14=new Movie("xx",1992,"xxx","10");
       m15=new Movie("xx",1992,"xxx","10");
       Mv.add(m1);
       Mv.add(m2);
       Mv.add(m3);
       Mv.add(m4);
       Mv.add(m5);
       Mv.add(m6);
       Mv.add(m7);
       Mv.add(m8);
       Mv.add(m9);
       Mv.add(m10);
       Mv.add(m11);
       Mv.add(m12);
       Mv.add(m13);
       Mv.add(m14);
       Mv.add(m15);

        //To add users to the library
        mr1=new Member("111-1111","xx","yy","zz","cab");
        mr2=new Member("111-1112","kk","xx","tt","ty");
        mr3=new Member("111-1113","rr","aa","bb","cc");
        mr4=new Member("111-1114","rr","aa","bb","cc");

        Mem.add(mr1);
        Mem.add(mr2);
        Mem.add(mr3);
        Mem.add(mr4);

    }

    void view_books()     //Function to view the list of books in the library
    {
       int i;
        System.out.print("Book ID    Book Name   Author     Category");

        for(i=0;i<Bk.size();i++)
        {

            Book st=Bk.get(i);
            System.out.println();
            System.out.print(st.id+"\t\t\t"+st.name+"\t\t\t"+st.author+"\t\t\t" +st.category);
        }
    }
    Boolean is_bookavailable(int bid)        //Function to check the book requested by the customer is available
    {
        int i;
        for(i=0;i<Bk.size();i++)
        {
            Book st=Bk.get(i);
            if(bid ==st.id )
            {

               return true;
            }

        }

        return false;

    }
    Boolean Authenticate_user(String uname,String pwd)

    {
        int i;
         for(i=0;i<Mem.size();i++)
        {
            Member me=Mem.get(i);
            if(uname.equalsIgnoreCase(me.uname) && pwd.equalsIgnoreCase(me.password))
            {

                return true;
            }

        }

        return false;

    }


    void view_details(String un)        //Function to view the membership details
    {
        int i;
        for(i=0;i<Mem.size();i++)
        {
            Member me=Mem.get(i);
            if(un.equalsIgnoreCase(me.uname))
            {
                System.out.println("NAME:"+me.name);
                System.out.println("EMAIL:"+me.email);
                System.out.println("PHONE NO:"+me.phno);
            }


        }
    }

    void view_movies()           //Function to view the list of movies available in the library
    {
        int i;
        System.out.print("Name        Year        Director       Rating");
        for(i=0;i<Mv.size();i++)
        {

            Movie m=Mv.get(i);
            System.out.println();
            System.out.print(m.name+"\t\t\t"+m.year+"\t\t\t"+m.director+"\t\t\t" +m.rating);

        }

    }




}
